package newsEventSystem;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class News {

	private String newsAuthor;
	private String informationSource;
	private Calendar publishedOn;
	private Calendar lastModified;
	private Domain domain;
	private int noViews;
	private String title;
	private String body;
	

	DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");

	public News(String newsAuthor, String informationSource, Domain domain,String title, String body) {
		this.newsAuthor = newsAuthor;
		this.informationSource = informationSource;
		this.domain = domain;
		publishedOn = Calendar.getInstance();
		lastModified = Calendar.getInstance();
		noViews = 0;
		this.title = title;
		this.body = body;
	}

	public void incrementViews(){
		this.noViews++;
	}
	public String getNewsAuthor() {
		return newsAuthor;
	}

	public String getInformationSource() {
		return informationSource;
	}

	public String getDomainName() {
		return domain.getDomainName();
	}

	public String getPublishingDate() {
		return dateFormat.format(publishedOn.getTime());
	}

	/* se apeleaza cand un editor modifica o stire */
	public void setModifiedDate() {
		lastModified = Calendar.getInstance();
	}

	public String getLastModifiedDate() {
		return dateFormat.format(lastModified.getTime());
	}

	public int getNoViews() {
		return noViews;
	}

	public String getTitle() {
		return title;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}
}